﻿Public Class Form1
    '文字格納
    Dim str As String
    '文字送り限度
    Dim part As Integer = 7
    'タイマー
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        '頭文字の位置
        Static front As Integer = 0
        '文字列終端
        Static backstr As Integer = str.Length
        Debug.WriteLine("front:" & front & vbCrLf & "part:" & part & vbCrLf & "backstr:" & backstr & vbCrLf & vbCrLf)
        '先頭文字が終端に達するまで
        If front < backstr Then
            '先頭文字が文字送り限度より大きくなったとき真
            If front > part Then
                'フォームの先頭文字を一文字削除
                Me.Text = Me.Text.Remove(0, 1)
            End If
            '格納してある文字列からフォームの最後尾に一文字追加
            Me.Text = Me.Text & str.Chars(front)
        Else
            'タイトルクリア
            Me.Text = ""
            front = -1
        End If
        front += 1

    End Sub
    'ボタン
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '一応140?まで*未検証
        If RichTextBox1.TextLength <= 140 Then
            '入力文字を格納
            str = RichTextBox1.Text
            'タイマースタート
            Timer1.Start()
            'タイトルクリア
            Me.Text = ""
        End If

    End Sub
    'ロード
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Start Ready"
    End Sub

    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        Label1.Text = 140 - RichTextBox1.TextLength

    End Sub
End Class
